// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: common.hpp 223 2008-09-08 09:37:19Z heavyzheng $
//

#ifndef ZZHENG_LOGGING_COMMON_HPP_20080902__
#define ZZHENG_LOGGING_COMMON_HPP_20080902__

#include <zzheng/logging/config.hpp>
#include <string>

namespace zzheng {
namespace logging {

    //! Removes all illegal characters in the logger name. Legal characters that may appear in a
    //! logger's name are restricted to alphabetic characters and underscores.
    //! \param name  the name to process.
    //! \return a legal name with all the illegal characters removed.
    inline
    std::string remove_illegal_chars_in_name(const std::string& name) {
        std::string legal_name;
        legal_name.reserve(name.size());
        for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
            if ((*i >= 'a' && *i <= 'z') || (*i >= 'A' && *i <= 'Z') || (*i == '_')) {
                legal_name.push_back(*i);
            }
        }
        return legal_name;
    }

} // namespace zzheng::logging
} // namespace zzheng

#endif // ZZHENG_LOGGING_COMMON_HPP_20080902__



